const {createApp} = Vue
createApp({
	data() {
		return {
			apiServer:  `${window.location.protocol}//${window.location.hostname}:8089/`,
			curNaotu: {},
			naotuTips: "",
			shareID: window.location.search.substring(1),
			userinfo: {}
		}
	},
	//组件渲染完成
	mounted() {
		let t = this;
		angular.module("kityminderContainer", ["kityminderEditor"]).controller("MainController", ["$scope",	function(e) {e.initEditor = function(e, a) {window.editor = e, window.minder = a}}]), angular.bootstrap("#kityminderContainer");
		$.ajax({
			type: "GET",
			url: `${t.apiServer}map/share/${t.shareID}`,
			dataType: "json",
			success: function(data) {
				t.setCurrentNaotu(data.data);
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.responseJSON.msg);
			}
		});
	},
	methods: {
		setCurrentNaotu(data) {
			console.log(data);
			this.curNaotu = {
				id: data.id,
				title: data.title,
				data: JSON.parse(data.data),
				deleted: data.deleted,
				createBy: data.createBy,
				updateBy: data.updateBy,
				createdAt: data.createdAt,
				updatedAt: data.updatedAt,
				userId: data.userId
			};
			editor.minder.importJson(this.curNaotu.data);
			this.naotuTips = "当前打开的是共享文档！";
		}
	}
}).mount('#mainContainer')
